from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from feedbag.apps.blog.feeds import BlogFeed
from feedbag.apps.blog.sitemap import post_sitemap
from feedbag.apps.product.sitemap import product_sitemap


# Uncomment the next two lines to enable the admin:
admin.autodiscover()

sitemaps = {
    'blog': post_sitemap(),
	'product': product_sitemap(),
}

urlpatterns = patterns('feedbag.apps',
    #admin                    
    (r'^admin/', include(admin.site.urls)),
    
    #sitemap    
	#(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
        
    #brand
    url(r'^brands/$', 'product.views.brands', name="brands_view"),
    url(r'^products/$', 'product.views.products', name="products_view"),
    
    #reviews
    url(r'^reviews/$', 'product.views.reviews', name="reviews_view"),
    url(r'^reviews/(?P<slug_brand>[a-zA-Z0-9_.-]+)/(?P<slug_product>[a-zA-Z0-9_.-]+)/$', 'product.views.product', name='product_view'),
    url(r'^reviews/(?P<slug_brand>[a-zA-Z0-9_.-]+)/$', 'product.views.brand', name='brand_view'),
    
    #blog
    url(r'^blog/$', 'blog.views.blog', name="blog_view"),
    url(r'^blog/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>[a-zA-Z0-9-]+)$', 'blog.views.post', name="post_view"),
    url(r'^blog/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', 'blog.views.archive_day', name="post_archive_day_view"),
    url(r'^blog/(?P<year>\d{4})/(?P<month>\d{1,2})/$', 'blog.views.archive_month', name="post_archive_month_view"),
    url(r'^blog/(?P<year>\d{4})/$', 'blog.views.archive_year', name="post_archive_year_view"),
    url(r'^blog/rss/$', BlogFeed(), name='blog_rss'),

    #common
    url(r'^sitemap/$', 'common.views.sitemap', name="sitemap_view"),
    url(r'^accessibility/$', 'common.views.accessibility', name="accessibility_view"),
    url(r'^terms-and-conditions/$', 'common.views.terms', name="terms_view"),
    
    url(r'^$', 'home.views.home', name="home_view"),
)

urlpatterns += patterns('',
        (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)

urlpatterns += patterns('', 
		(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
)
